package fr.cephb.operonj.core.db.key;



public class SequenceIndex
	extends BuildChrom
	implements Comparable<SequenceIndex>
	{
	private static final long serialVersionUID = 1L;
	public static final int SIZE=100000;
	private int index;//oui e.g. reader.read(array) return int. avoir casting 
	
	public SequenceIndex(BuildChrom chr, int index)
		{
		this(chr.getBuildId(),chr.getChromId(),index);
		assert(index%SIZE==0);
		}
	
	public SequenceIndex(int buildId,int chromId, int index)
		{
		super(buildId,chromId);
		this.index=index;
		}
	
	
	public int getIndex()
		{
		return index;
		}
	
	@Override
	public int compareTo(SequenceIndex o)
		{
		int n=getBuildId()-o.getBuildId();
		if(n!=0) return n;
		n= getChromId()-o.getChromId();
		if(n!=0) return n;
		long m= index-o.index;
		return m==0?0:(m<0L?-1:1);
		}
	@Override
	public String toString()
		{
		return "{build:"+getBuildId()+" chrom:"+getChromId()+" at:"+getIndex()+"}";
		}
	}
